package com.xintonghua.bussiness.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.xintonghua.base.adapter.BaseAdapter;
import com.xintonghua.base.widget.ShowAllGridView;
import com.xintonghua.bussiness.R;
import com.xintonghua.bussiness.bean.GroupLogBean;
import com.xintonghua.bussiness.util.GlideUtils;
import com.xintonghua.bussiness.util.MyUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 作者：wanxianyi
 * 时间：2018/1/11.
 * 包名：com.xintonghua.bussiness.adapter
 */

public class GroupLogAdapter extends BaseAdapter<GroupLogBean, GroupLogAdapter.ClientViewHolder> {


    public GroupLogAdapter(Activity mActivity, List<GroupLogBean> list) {
        super(mActivity, list);
    }

    @Override
    public ClientViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.adapter_group_log, parent, false);
        return new ClientViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ClientViewHolder holder, int position) {
        GroupLogBean bean = list.get(position);
        holder.tvLogUsername.setText(bean.getName());
        holder.tvLogPositionName.setText(bean.getPositionName());
        holder.tvLogPhone.setText(bean.getPhone());
        holder.tvLogTime.setText(bean.getCreate_time());
        holder.tvLogContent.setText(bean.getContent());
        GlideUtils.loadCricle(mActivity, holder.tvLogHead, bean.getImg(), R.drawable.default_head);
        List<String> imgeList = MyUtils.getListStringSplitValue(bean.getImgs());
        holder.gvLogPic.setAdapter(new ImageAdapter(imgeList, mActivity));
    }


    class ClientViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_log_head)
        ImageView tvLogHead;
        @BindView(R.id.tv_log_username)
        TextView tvLogUsername;
        @BindView(R.id.tv_log_positionName)
        TextView tvLogPositionName;
        @BindView(R.id.tv_log_phone)
        TextView tvLogPhone;
        @BindView(R.id.tv_log_time)
        TextView tvLogTime;
        @BindView(R.id.tv_log_content)
        TextView tvLogContent;
        @BindView(R.id.gv_log_pic)
        ShowAllGridView gvLogPic;

        public ClientViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
